
#include "i2cReg.h"
#include "ymaker-nrf24l01.h"

nrf24l01Class nrf24l01;
#define TXMODE

const uint8_t RXADD[]="add01";

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Wire.begin(); 
  delay(110); 
  Serial.begin(115200);
  nrf24l01.setRxAdd(RXADD);
}

void loop() {

   uint8_t tbuf[5];
   uint8_t rbuf[5];
   static uint16_t i=0;  
   static uint16_t v=0; 
#ifdef TXMODE
   tbuf[0]=i/1000+0x30;
   tbuf[1]=i%1000/100+0x30;
   tbuf[2]=i%100/10+0x30;
   tbuf[3]=i%10+0x30;
   i++;
   if(i>9999)i=0;

  if(nrf24l01.writeReadData("add01",tbuf,rbuf))
  {
      rbuf[4]='\0';
      Serial.print("add01-------");
      Serial.println((char *)rbuf);    
  }
  if(nrf24l01.writeReadData("add02",tbuf,rbuf))
  {
      rbuf[4]='\0';
      Serial.print("add02-------");
      Serial.println((char *)rbuf);    
  }
  if(nrf24l01.writeReadData("add03",tbuf,rbuf))
  {
      rbuf[4]='\0';
      Serial.print("add03-------");
      Serial.println((char *)rbuf);    
  }
#else 
  if(nrf24l01.readData(rbuf)==true)
  {
    nrf24l01.writeData(RXADD,4,rbuf);
//    rbuf[4]='\0';
//    Serial.println((char *)rbuf);
          
  }
#endif





}
